package com.xiaofang.controller.indexcontrolelr;

import com.xiaofang.pojo.User;
import com.xiaofang.serivce.UserSerivc;
import com.xiaofang.utils.Ajax;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: xiaofangbackend
 * @ClassName LoginController
 * @description:
 * @author: aodi
 * @create: 2025-06-20 11:18
 * @Version 1.0
 */
@RestController
@RequestMapping("/xiaofang/user")
public class LoginController {

   @Autowired
    private UserSerivc userSerivc;

//   用户登入
    @PostMapping("/login")
    public Ajax login( @RequestBody User user) {

        User user1 = null ;
        try {
             user1 = userSerivc.getUser(user);
        } catch (Exception e) {
            e.printStackTrace();
             return new Ajax("500","用户不存在");
        }
         return  new Ajax("200","登入成功" ,user1) ;

    }

}
